<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<c:set var="webroot" value="${pageContext.request.contextPath}" />
<script type="text/javascript"
	src="${webroot}/static/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript"
	src="${webroot}/static/js/bootstrap.min.js"></script>
<script type="text/javascript"
	src="${webroot}/static/js/bootstrap-table.js"></script>

<script type="text/javascript" src="${webroot}/static/js/layer/layer.js"></script>
<script src="${webroot}/static/js/jquery.form.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css"
	href="${webroot}/static/js/layer/skin/layer.css" />
<link rel="stylesheet" type="text/css"
	href="${webroot}/static/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css"
	href="${webroot}/static/css/bootstrap-table.min.css" />
<head>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<style type="text/css">
.layui-btn-container .layui-btn+.layui-btn {
    margin-left: 0;
}
.layui-btn-container .layui-btn {
    margin-right: 10px;
    margin-bottom: 10px;
}

.layui-btn+.layui-btn {
    margin-left: 10px;
}
.layui-btn {
    display: inline-block;
    height: 38px;
    line-height: 38px;
    padding: 0 18px;
    background-color: #009688;
    color: #fff;
    white-space: nowrap;
    text-align: center;
    font-size: 14px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
}
.layui-btn-primary {
    border: 1px solid #C9C9C9;
    background-color: #fff;
    color: #555;
}
.layui-btn-normal {
    background-color: #1E9FFF;
}
</style>
</head>
<body style="overflow-x: hidden;">
	<div style="padding: 38px 140px; margin: 1px;">
	    <h4 style="display:inline-block;vertical-align: top;">规则说明:</h4>
		<div style="width: 75%;display:inline-block">
			<script id="agreementText" type="text/plain" style="height: 600px;"></script>
		</div>
        <div style="padding-left: 38%; padding-top: 18px;">
			<input type="button" class="layui-btn layui-btn-normal" onclick="save();" value="确认">&nbsp;&nbsp;
			<input type="button" class="layui-btn layui-btn-primary" onclick="cole();" value="取消">
		</div>
	</div>
</body>
<script src="${webroot}/static/js/utf8-jsp/ueditor.config.js"
	type="text/javascript"></script>
<script src="${webroot}/static/js/utf8-jsp/ueditor.all.js" type="text/javascript"></script>
<script type="text/javascript">
var ue = UE.getEditor('agreementText', {
	readonly : "2" == "1" ? true : false,
		/* 	  toolbars: [
			            ['source','undo', 'redo', 'bold', 'italic', 'underline','justifyleft','emotion','simpleupload','formatmatch','autotypeset','inserttable','directionalityltr','directionalityrtl','attachment']
			      ],  */
			       autoHeightEnabled: true,
			       initialFrameWidth : 1000
});
UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
UE.Editor.prototype.getActionUrl = function(action) {
    if ( action == 'uploadimage' ||  action == 'uploadvideo' ||  action == 'uploadfile') {
    	if(action == 'uploadvideo'){
    		return '${webroot}/videoUpload';
    	}
    	if(action == 'uploadfile'){
    		return '${webroot}/fileUpload';
    	}
    	return '${webroot}/imgUpload';
    } else {
        return this._bkGetActionUrl.call(this, action);
    }
}

$(function(){
 	$.ajax({
		url : "${webroot}/guide/querypage",
		type : "POST",
		dataType : "json",
		data:{
			type : 6
		},
		async : false,
		cache : false,
		success : function(obj) {
			if(obj.length > 0){
				$("#agreementText").val(obj[0].pictureUrl);
			}
		}
	});
});

function save(){
	var html = ue.getContent();
	if(html == ''){
		return;
	}
 	$.ajax({
		url : "${webroot}/guide/updateWe",
		type : "POST",
		dataType : "json",
		data:{
			picture : html,
			type : 6
		},
		async : false,
		cache : false,
		success : function(obj) {
			 if(obj.success){
				 layer.msg("操作成功");
             }else{
           	  layer.msg(obj.message);
             }
		}
	});
}

function cole(){
	ue.setContent('');
}
</script>
</html>
